const {
    Container,
    Maybe
} = require("./support.js");
const fp = require("lodash/fp");

let maybe = Maybe.of([5, 6, 1]);

let ex1 = () => {
    return maybe.map(fp.map(val => fp.add(1)(val)))._value;
}
console.log(ex1());

let xs = Container.of([
    "do", "ray", "me", "fa", "so", "la", "ti", "do"
]);

let ex2 = () => {
    return xs.map(fp.first)._value;
}

console.log(ex2());


let safeProp = fp.curry(function (x, o) {
    return Maybe.of(o[x]);
});
let user = {
    id: 2,
    name: "Albert"
};

// let ex3 =  safeProp("name")(user).map(fp.first);
let ex3 = (x, o) => {
    return safeProp(x, o).map(fp.first)._value
};
console.log(ex3("name", user));



let ex4 = function (n) {
    if (n) return parseInt(n);
}

ex4 = (n) => Maybe.of(n).map(parseInt)._value;

console.log(ex4("3.0"))